<template>
    <div class="address-warning">
        <div class="address-early-warning">异常上报</div>
        <div style="padding: 20px 16px;background-color: #fff">
            <lar-table model="express.order"
                       action="base.table.abnormal"
                       @handelButton="handelButton">
            </lar-table>
        </div>

    </div>
</template>
<script>

    export default {
        data() {
            return {
                allData: {
                    navList: [],
                    objData: {},
                    current: '',
                    checkIndex: '0'
                },
                // navList: [],
                // objData: {},
                timer: null,
                index: null
            }
        },
        computed: {
            dataRefreshDialog() {
                return this.$store.state.num;
            },
            checkIndex() {
                return this.allData.checkIndex;
            },
            current() {
                return this.allData.current;
            }
        },
        watch: {
            dataRefreshDialog: function (newValue) {
                this.getNavList();
                this.getStatisticsData()
            },
        },
        // mounted() {
        //     this.getNavList();
        //
        //     this.getStatisticsData()
        //     // this.timer = setInterval(() =>{
        //     //     this.$store.commit('refreshDialog');
        //     // }, 30000);
        //     this.$once('hook:beforeDestroy', () => {
        //         clearInterval(this.timer);
        //     })
        // },
        methods: {
            handelButton(event, val) {
                //批量指派
                if (event.action == 'reback') {
                    for (let k in val) {
                        let tid = val[k].id;
                        this.$http.put('/express/order/' + tid, {'dispatch_status': 0})
                            .then((response) => {
                                this.loading = false;
                                this.$message({
                                    showClose: true,
                                    message: '恢复成功,请刷新查看',
                                    type: 'success'
                                });
                            })
                            .catch((error) => {
                                this.loading = false;
                                this.$message.error('请求错误');
                                console.log(error);
                            });
                    }

                }
            }


            // getNavList() {   // 获取导航数据
            //     this.$http.get('express/order/nav?dispatchType=' + this.allData.checkIndex)
            //         .then((response) => {
            //             // this.navList = response.data.data;
            //             this.allData.navList = response.data.data;
            //             this.allData.current = this.allData.navList?this.allData.navList[0].type:'';
            //         })
            //         .catch((error) => {
            //             if (error.response.data.msg) {
            //                 this.$message.error(error.response.data.msg);
            //             } else {
            //                 this.$message.error('请求错误：' + error.response.status);
            //             }
            //         });
            // },
            // getStatisticsData() {  // 获取统计数据
            //     this.$http.get('express/order/dispatch_count')
            //         .then((response) => {
            //             // this.objData = response.data.data;
            //             this.allData.objData = response.data.data;
            //         })
            //         .catch((error) => {
            //             if (error.response.data.msg) {
            //                 this.$message.error(error.response.data.msg);
            //             } else {
            //                 this.$message.error('请求错误：' + error.response.status);
            //             }
            //         });
            // },

        }
    }
</script>
<style lang="less" scoped>
    .address-warning{
        margin: 10px;
        background-color: #fff;
        .address-early-warning{
            box-sizing: border-box;
            border-bottom: 2px solid #eee;
            font-size: 16px;
            padding:6px 0 6px 16px;
            /*margin-bottom: 2px;*/
            background-color: #fff;
        }
    }
</style>

